# def func():
#     print("我是周杰伦")
#     yield "小米"  # 函数中包含了yield 当前这个函数就不再是普通的函数；是生成器函数
#     print("我是王力宏")
#     yield "嘻嘻"
#     print("帝吧")
#     yield "hehe"
#     print("你好")  # 最后一个yield之后如果再进行__next__() 会报错
#
#
# g = func()
# print(g.__next__())
# print(g.__next__())
# print(g.__next__())

"""
yield 可以返回结果 也可以让函数分段执行
"""


# def fun():
#     lst = []
#     for i in range(1, 1001):
#         lst.append(f"衣服{i}")
#     return lst
#
#
# f = fun()
# print(f)

# def gen():
#     i = 1
#     while i < 1001:
#         yield f"衣服{i}"
#         i = i + 1
#
#
# g = gen()
# print(g.__next__())
# print(g.__next__())
# print(g.__next__())
# print(g.__next__())
# print(g.__next__())
# print(g.__next__())


def func():
    yield 11
    yield 12
    yield 13
    yield 14


# f 拿到的是生成器 生成器的本质是迭代器 迭代器可以被迭代 生成器可以直接for 循环
f = func()

for i in f:
    print(i)
